<?php

class Validation{function rule($f,$r){@$this->r[$f][]=$r;}function check(array$d){list($this->results,$r)=validate($d,@$this->r);return$r;}}
function validate($d,$r){foreach($d as$k=>&$v)$v=is_array(@$r[$k])&&valid_field($v,$r[$k]);return array($d,array_sum($d)==count($d));}
function valid_field($v,$r){$b=1;foreach($r as$f)if(!$b=$b&&@call_user_func($f,$v))break;return(bool)$b;}

/* EXAMPLE USAGE
$data = array('first' => 'Jeremy', 'last' => 'Lindblom');
$validation = new Validation;
$validation->rule('first','is_string');
$validation->rule('first','is_scalar');
$validation->rule('last','is_string');
$is_valid = $validation->check($data);
$data_results = $validation->results;
var_dump($is_valid, $data_results);
*/